/**
 事件校验
 */
<template>
  <div>
    <label>email:</label><input v-model="email"/>
    <label>email:</label><input v-model="password"/>
    <button @click="submitForm(email, password)">submit</button>
  </div>
</template>

<script setup>
import {ref} from 'vue'
const emit = defineEmits({
    // 没有校验
  click: null,

  // 校验 submit 事件
  submit: ({ email, password }) => {
    console.log(email, password)
    if (email && password) {
      return true
    } else {
      console.warn('Invalid submit event payload!')
      return false
    }
  }
})

const email = ref('');
const password = ref('');

function submitForm (email, password) {
    emit('submit', {email, password})
}
</script>

<style>

</style>